/*
 * @Author: dmyang
 * @Date:   2015-08-31 21:17:45
 * @Last Modified by:   dmyang
 * @Last Modified time: 2016-03-28 09:48:22
 */

'use strict'

import 'commonCss'



// 直接使用npm模块

require('../css/main.css')
require('../css/swiper.min.css')
require('../js/lib/swiper.min.js')

let report = require('./helpers/report')
let bar = require('./helpers/bar')
let url = require('./utils/url')
let $ajax = require('./helpers/ajax')
require('./utils/site')

let news = site.tpl('new')

let name = site.QueryString('type')


function handler () {
    site.getToken(render)
}



function render(){
    site.header()
    site._ajax({
        type:'GET',
        url: HTTP_SERVER + 'cms/api/websites/89060613317206016',
        data:{},
        success: function (res) {
            site.footer(res)
        }
    })
    site.setNav(main)
}
function main(data) {
    let id = site.QueryString('id')?site.QueryString('id'):1

    site._ajax({
        type:'GET',
        url:HTTP_SERVER+'information/api/categories/88699571919675392/information',
        data:{page:0,size:4,sort:'displayOrder,desc'},
        success: function(res){
            let arr = []
            for(let i = 0; i < res.totalPages; i++){
                arr[i] = i
            }
            let page = {totalPages:arr,number:res.number}
            news({list:res.content,page:page})
        }
    })

    site._ajax({
        type:'GET',
        url:HTTP_SERVER+'cms/api/pages/2/properties',
        data:{},
        success: function(res){
            site.banner('108261156153511936',{proList:site.nav[1].children})
        }
    })
}

document.addEventListener('visibilitychange', handler)
window.addEventListener('DOMContentLoaded', handler)
window.addEventListener('resize', handler)





